package com.mtw.bbs.article.feign;

import com.mtw.bbs.article.pojo.vo.SimpleArticleVo;
import com.mtw.bbs.common.core.vo.Result;
import com.mtw.bbs.common.web.interceptor.BaseFeignInterceptor;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import static com.mtw.bbs.common.core.constant.ApiPrefix.API_PREFIX_ARTICLE;


@FeignClient(name = "bbs-article",
        contextId = "articleClientI",
        configuration = BaseFeignInterceptor.class,
        fallback = ArticleClient.ArticleClientFallback.class)
public interface ArticleClient {




    /**
     * 根据id获取简单文章
     */
    @ApiOperation(value = "根据id获取简单文章", notes = "传入文章id集合")
    @PostMapping(value = API_PREFIX_ARTICLE + "/getArticleById",headers = "Content-Type=application/json")
    Result<List<SimpleArticleVo>> getArticleById(@RequestBody String[] ids);



    @Component("articleClient")
    class ArticleClientFallback implements ArticleClient{


        @Override
        public Result<List<SimpleArticleVo>> getArticleById(String[] ids) {
            return Result.fail("获取失败");
        }
    }
}

